package kr.hkit.powerjava.chapter13;

import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.HeadlessException;
import java.awt.Image;
import java.awt.Toolkit;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;

class MainPanel extends JPanel{
	public MainPanel(){
		 
		JButton btl01 = new JButton("버튼1");
		btl01.setBorderPainted(false);
		btl01.setContentAreaFilled(false);
		btl01.setEnabled(false);
		
		JButton btl02 = new JButton("버튼2");
		btl02.setRolloverEnabled(true);
		JLabel lbl01= new JLabel();
		
		JPanel mainPanel = new JPanel(new FlowLayout());
		
		mainPanel.add(lbl01);
		mainPanel.add(btl01);
		mainPanel.add(btl02);
		mainPanel.setToolTipText("!@#!@#!@#");
	}
	
}

class TfPanel extends JPanel{
	public TfPanel(){
		
		JTextField jtf01 = new JTextField(10);
		JTextField jtf02 = new JTextField("텍스트 필드 테스트", 10);
		
		JPanel tfPanel = new JPanel();
		
		tfPanel.add(jtf01);
		tfPanel.add(jtf02);
	}
}
class MyFrame extends JFrame {
	public MyFrame() throws HeadlessException {
		Toolkit tool = Toolkit.getDefaultToolkit();
		Dimension screenSize = tool.getScreenSize();
		Dimension frameSize = new Dimension(300, 200);
		
		int x = (int) (screenSize.getWidth() / 2 - frameSize.getWidth() / 2);
		int y = (int) (screenSize.getHeight() / 2 - frameSize.getHeight() / 2);
		
		setLocation(x, y);
		setSize(frameSize);
		
		Image img = tool.getImage("Hydrangeas.jpg");
		setIconImage(img);
		
		
		setTitle("Frame Test2");
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		
		setLayout(new FlowLayout());
	
		
		add(new MainPanel());
		add(new TfPanel());
		pack();
		setVisible(true);
	}
}

public class FrameTest {
	public static void main(String[] args) {
		new MyFrame();
//		JFrame f = new JFrame("Frame Test");
//		f.setSize(new Dimension(300, 200));
//		f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//		f.setVisible(true);
	}
}
